package com.li.learning.train.enums;

/**
 * @author : leapzed
 * @date : 2023-06-24
 * 答题正确状态枚举类
 */
public enum CommitAnswerStatusEnums {

    CORRECT("回答正确", 1),
    ERROR("回答错误", 0);

    // 成员变量
    private String name;
    private int index;

    // 构造方法
    private CommitAnswerStatusEnums(String name, int index) {
        this.name = name;
        this.index = index;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public static String  getName(int index){
        for (CommitAnswerStatusEnums status : values()) {
            if(status.getIndex() == index){
                return  status.getName();
            }
        }
        return "";
    }

    public static int  getIndex(String name){
        for (CommitAnswerStatusEnums status : values()) {
            if(name.equals(status.getName())){
                return  status.getIndex();
            }
        }
        return 0;
    }

}
